<div class="easyui-layout" data-options="fit:true">
	<!-- Begin of toolbar -->
	<div id="wu-toolbar-3">
		<div class="wu-toolbar-search">
			<label>用户名称：</label><input id="unames" class="wu-text" style="width:100px">
			<a href="#" class="easyui-linkbutton" onclick="selectRoles()" iconCls="icon-search">开始检索</a>
		</div>
	</div>
	<!-- End of toolbar -->
	<table id="wu-datagrid-3" class="easyui-datagrid" toolbar="#wu-toolbar-3"></table>
</div>
<!-- End of easyui-dialog -->
<script type="text/javascript">
	/**
	 * 页面加载事件
	 */
	$(function() {
		selectRoles();
	})

	/**
	 * 查詢角色信息
	 */
	function selectRoles() {
		$('#wu-datagrid-3').datagrid({
			url: globalData.server + "journal/selectPage",
			queryParams: {
				token: globalData.getToken(),
				uname: $("#unames").val()
			},
			onLoadSuccess: function(data) {
				$("a[name='sc']").linkbutton(({
					text: "删除",
					iconCls: "icon-remove",
				}))
			},
			rownumbers: true,
			pageSize: 4,
			pageList: [4, 5, 6],
			pagination: true,
			multiSort: true,
			fitColumns: true,
			fit: true,
			columns: [
				[{
					field: 'uname',
					title: '用户名称',
					width: 80
				}, {
					field: 'landTime',
					title: '操作时间',
					width: 80
				}, {
					field: 'url',
					title: '操作路径',
					width: 80
				}, {
					field: 'scheme',
					title: '操作协议',
					width: 80
				}, {
					field: 'caozuo',
					title: '删除',
					width: 50,
					formatter: deleteJournal
				}]
			]
		});
	}


	function deleteJournal(value, row, index) {
		return "<a   class='easyui-linkbutton' name='sc'  onclick='udeletes(" + index +
			")'>删除信息</a>"
	}

	/**
	 * 删除按钮
	 * @param {Object} index
	 */
	function udeletes(index) {
		var delId = $("#wu-datagrid-3").datagrid("getData");
		var row = delId.rows[index].jid;
		$.messager.confirm('确认', '您确认想要删除记录吗？', function(r) {
			if(r) {
				$.post(globalData.server + "journal/deleteJournal?token=" + globalData.getToken() + "&jid=" + row, function(res) {
					if(res=0) {
						$.messager.alert('删除失败', "删除失败");
					} else {
						$.messager.alert('删除成功', '成功');
						$("#wu-datagrid-3").datagrid("reload");
					}
				}, "json");
			}
		});
	}
</script>

